<?php

/**
 * @Entity(repositoryClass="DefaultDb_Repositories_UserRepository")
 * @Table(name="users")
 */
class DefaultDb_Entities_User
{
    /* constantes para tipo de usuario */
    const USER_ADMIN = 1;
    const USER_DRIVER = 2;
    const USER_CLIENT = 3;
    const USER_SECRETARY = 4;
    const USER_CLIENT_MAS_DISTRIBUCION = 5;

    /* constantes para tipo de usuario */
    const STATUS_INACTIVE = 0;
    const STATUS_ACTIVE = 1;
    const STATUS_BLOCK = 2;
    
    /* constantes para el dia que desea tener el usuario para facturar */
    const DAY_MONDAY = 1;
    const DAY_TUESDAY = 2;
    const DAY_WEDNESDAY = 3;
    const DAY_THURSDAY = 4;
    const DAY_FRIDAY = 5;
    const DAY_SATURDAR = 6;
    const DAY_SUNDAY = 7;
    /**
     * @Id @GeneratedValue @Column(type="integer")
     * @var integer
     */
    protected $id;

    /**
     * @Column(type="string", name="code")
     * @var string
     */
    protected $code;

    /**
     * @Column(type="integer", name="status" , options={"default" = 1})
     * @var integer
     */
    protected $status = 1;
    
    /**
     * @Column(type="string", name="first_name")
     * @var string
     */
    protected $firstName;

    /**
     * @Column(type="string", name="last_name")
     * @var string
     */
    protected $lastName;

    /**
     * @Column(type="string", name="username")
     * @var string
     */
    protected $username;

    /**
     * @Column(type="string", name="password")
     * @var string
     */
    protected $password;

    /**
     * @Column(type="string", name="title", nullable=true)
     * @var string
     */
    protected $title;

    /**
     * @Column(type="string", name="commercial_name", nullable=true)
     * @var string
     */
    protected $commercialName;

    /**
     * @Column(type="string", name="cell_phone", nullable=true)
     * @var string
     */
    protected $cellPhone;

    /**
     * @Column(type="string", name="local_number", nullable=true)
     * @var string
     */
    protected $localNumber;

    /**
     * @Column(type="string", name="type", nullable=true)
     * @var string
     */
    protected $type;

    /**
     * @OneToMany(targetEntity="DefaultDb_Entities_Catalog", mappedBy="client")
     * */
    private $catalogs;

    /**
     * @OneToMany(targetEntity="DefaultDb_Entities_M3CommerceOrder", mappedBy="seller")
     * */
    private $ordersReceived;

    /**
     * @OneToMany(targetEntity="DefaultDb_Entities_M3CommerceOrder", mappedBy="buyer")
     * */
    private $ordersGenerated;

    /**
     * @ManyToOne(targetEntity="DefaultDb_Entities_Category")
     */
    protected $category;

    /**
     * @ManyToOne(targetEntity="DefaultDb_Entities_Point")
     */
    protected $point = 0;
    
    /**
     * @Column(type="integer", name="dayInvoice")
     * @var integer
     */
    protected $dayInvoice = 0;
    
    /**
     * @OneToMany(targetEntity="DefaultDb_Entities_BranchesUser", mappedBy="client")
     **/
    private $branches;
    
    public function getId()
    {
        return $this->id;
    }

    public function getStatus()
    {
        return $this->status;
    }

    public function getFirstName()
    {
        return $this->firstName;
    }

    public function getLastName()
    {
        return $this->lastName;
    }

    public function getFullName()
    {
        return $this->firstName . ' ' . $this->lastName;
    }
    
    public function getCode()
    {
        return $this->code;
    }

    public function setCode($code)
    {
        $this->code = $code;
    }

    public function getUsername()
    {
        return $this->username;
    }

    public function getPassword()
    {
        return $this->password;
    }

    public function getTitle()
    {
        return $this->title;
    }

    public function getCommercialName()
    {
        return $this->commercialName;
    }

    public function getType()
    {
        return $this->type;
    }

    public function getCellPhone()
    {
        return $this->cellPhone;
    }

    public function getLocalNumber()
    {
        return $this->localNumber;
    }

    public function getCategory()
    {
        return $this->category;
    }

    public function getDayInvoice()
    {
        return $this->dayInvoice;
    }
    
    public function getBranches()
    {
        return $this->branches;
    }
    
    public function setId($id)
    {
        $this->id = $id;
    }

    public function setStatus($status)
    {
        $this->status = $status;
    }

    public function setFirstName($firstName)
    {
        $this->firstName = $firstName;
    }

    public function setLastName($lastName)
    {
        $this->lastName = $lastName;
    }

    public function setUsername($username)
    {
        $this->username = $username;
    }

    public function setPassword($password)
    {
        $this->password = $password;
    }

    public function setTitle($title)
    {
        $this->title = $title;
    }

    public function setCommercialName($commercialName)
    {
        $this->commercialName = $commercialName;
    }

    public function setType($type)
    {
        $this->type = $type;
    }

    public function setCellPhone($cellPhone)
    {
        $this->cellPhone = $cellPhone;
    }

    public function setLocalNumber($localNumber)
    {
        $this->localNumber = $localNumber;
    }

    public function setCategory($category)
    {
        $this->category = $category;
    }

    public function setPoint($point)
    {
        $this->point = $point;
    }
    
    public function setDayInvoice($dayInvoice)
    {
        $this->dayInvoice = $dayInvoice;
    }

    public function getCatalogs()
    {
        return $this->catalogs;
    }

    public function getOrdersReceived()
    {
        return $this->ordersReceived;
    }

    public function getOrdersGenerated()
    {
        return $this->ordersGenerated;
    }

    public function getData()
    {
        $data = array();
        $data['id'] = $this->id;
        $data['firstName'] = $this->firstName;
        $data['lastName'] = $this->lastName;
        $data['username'] = $this->username;
        $data['type'] = $this->type;
        return $data;
    }

    public function getPoint()
    {
        return $this->point;
    }

    public function getTypeString($type = false)
    {
        $str = '';
        $current = $this->getType();
        
        if($type != false)
        {
            $current = $type;
        }

        switch($current)
        {
            case self::USER_ADMIN: $str = 'Administrador'; break;
            case self::USER_CLIENT: $str = 'Cliente'; break;
            case self::USER_DRIVER: $str = 'Conductor'; break;
            case self::USER_SECRETARY: $str = 'Secretaria'; break;
            
        }
        return $str;
    }

}
